package servlet.dispatch;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MakeErrorServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String url = null;
		try{
			int i = 10/0;
			url = "to go Success page";
		}catch(Exception e){
			e.printStackTrace();
			url = "/WEB-INF/jsp/error.jsp";// /의 의미 : 어플리케이션의 루트 경로(myservlet)
			request.setAttribute("error_message", "0으로 나눌 수 없습니다.");
		}
		//요청 디스패치 방식으로 수행을 url로 이동
		RequestDispatcher rdp = request.getRequestDispatcher(url);
		rdp.forward(request, response);
	}

}
